<?php

namespace app\apiweb\controller;

use app\common\controller\Api;
use think\Config;
use think\Exception;

/**
 * 栏目
 */
class WebType extends Api
{
    protected $noNeedLogin = '*';
    protected $noNeedRight = '*';

    protected $failException = true;

    public function _initialize()
    {
        parent::_initialize();
        $this->model = new \app\apiweb\model\WebType();
        if (!Config::get('fastadmin.usercenter')) {
            $this->error(__('User center already closed'));
        }
    }

    /**
     * 列表
     * @return void
     */
    public function list()
    {
        try {
            $data = $this->model
                ->order('id asc')
                ->field('*')
                ->select();
            $data = getInfinitus($data->toArray());
            $this->success('ok', $data);
        } catch (Exception $e) {
            $this->error($e->getMessage());
        }
    }

}